/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.bid.service.cacheplugins  
 */
package com.apache.bid.service.cacheplugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.bid.common.WbdToolsUtil;
import com.apache.bid.entity.BidItemGroup;
import com.apache.bid.manager.BidItemGroupManager;
import com.apache.cache.util.Validator;

/**
 * description:  修改分组信息
 * @author Hou Dayu 创建时间：2016-3-23  
 * 
 */
public class SaveItemGroupPluginImpl implements PluginConnector {

	private BidItemGroupManager bidItemGroupManager;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.zbxsoft.api.manager.PluginConnector#execute(com.zbxsoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo param) throws Exception {
		BidItemGroup pub = new BidItemGroup();
		pub = (BidItemGroup) WbdToolsUtil.getInstance().convert2Bean(param.getParams(), pub);
		ResultEntity entity = new ResultEntity();
		if (Validator.isNull(pub.getGroupName())) {
			entity.setResult("false");
			entity.setMessage("缺少方法参数,方法执行失败");
		} else {
			ParamsVo<BidItemGroup> vo = new ParamsVo<BidItemGroup>();
			vo.setObj(pub);
			String groupId = bidItemGroupManager.saveInfo(vo);
			entity.setResult("true");
			entity.setMessage("规则信息保存成功");
			entity.setEntity(groupId);
		}
		return entity;
	}

	public void setBidItemGroupManager(BidItemGroupManager bidItemGroupManager) {
		this.bidItemGroupManager = bidItemGroupManager;
	}

}
